import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.*;

import javax.swing.*;
import java.util.*;


public class Spot
{
	private JButton button;
	private Piece piece;
	
/*	Taking out for now
 
	public Spot()
	{
		ImageIcon emptySpot = new ImageIcon("images/emptySpot.gif", "an empty space");
		button = new JButton(emptySpot);
	}
	public Spot(Piece p)
	{
		piece = p;
		button = new JButton(p.getImage());
	}
*/
	

	public Spot(Board.ButtonListener listener)
	{
		button = new JButton(new Empty().getImage());
		
		button.setPreferredSize(new Dimension(60, 60));
		button.setBorderPainted(true);
		button.setLayout(null);
		button.addActionListener(listener);
	}
	
	public Spot(int x, int y, boolean isWhite, Board.ButtonListener listener)
	{
		piece = new Empty(x, y);
		button = new JButton(piece.getImage());
		
		button.setPreferredSize(new Dimension(60, 60));
		button.setBorderPainted(true);
		button.setLayout(null);
		button.addActionListener(listener);
	}
	public Spot(Piece p, ActionListener listener)
	{
		piece = p;
		button = new JButton(p.getImage());
		button.addActionListener(listener);
	}
	
	public void update()
	{
		piece.updateImage();
		button.setIcon(piece.getImage());
//		System.out.println("I am updating myself!");
	}
	
	public void setPiece(Piece p)
	{
		piece = p;
		update();
	}
	public JButton getButton()
	{
		return button;
	}
	
	public Piece getPiece()
	{
		return piece;
	}
	
	
	public void addListener(ActionListener listener)
	{
		button.addActionListener(listener);
	}
}
